package com.andnnl.pool.handle;

import com.andnnl.pool.IMsgHandle;
import com.andnnl.pool.Msg;
import com.andnnl.pool.TaskManage;

/**
 * Created by chenss on 2022/6/10.
 */
public abstract class AbsMsgHandle<T> implements IMsgHandle<T> {
    TaskManage<T> taskManage = null;

    @Override
    public void setTaskManage(TaskManage<T> tm) {
        this.taskManage = tm;
    }

    public void save(T m) {
        taskManage.addMsg(getKey(m), new Msg(m));
    }

    /**
     * key
     *
     * @param m
     * @return
     */
    protected abstract String getKey(T m);
}
